#ifndef BASE_ENDPOINT_H
#define BASE_ENDPOINT_H

#include "endpoint_addr.h"

namespace usnet {
class BaseEndpoint {
public:
    BaseEndpoint(const struct sockaddr_in& sockaddr):addr_ { sockaddr }
    {
        // nothing to do
    }
    BaseEndpoint(const struct sockaddr_in6& sockaddr):addr_ { sockaddr }
    {
        // nothing to do
    }
    inline const EndpointAddr& GetEndpointAddr() const
    {
        return addr_;
    }

    virtual ~BaseEndpoint() = default;
    virtual int Connect(const BaseEndpoint* rep) = 0;
    virtual int Accept() = 0;
    virtual int Close(const int fd) = 0;
    virtual int Send(const int fd, const char* data, const uint32_t len) = 0;
    virtual int Recv(const int fd, char* buf, const uint32_t len) = 0;
    virtual int Send(const int fd, const struct iovec* iov, const uint32_t len) = 0;
    virtual int Recv(const int fd, struct iovec* iov, const uint32_t len) = 0;
#ifndef NATIVE_SOCKET
    virtual uint32_t Recv(const int fd, const struct iovec** iov, const uint32_t size) = 0;
    virtual uint32_t Reserve(const int fd, const struct iovec** iov, const uint32_t size) = 0;
    virtual void Discard(const int fd, const struct iovec* iov) = 0;
    virtual bool Commit(const int fd, const struct iovec* iov) = 0;
#endif
    
protected:
    EndpointAddr addr_;
};
} // end of namespace usnet
#endif